---
description: Aggregation query permissions
keywords:
  - hasura
  - docs
  - permissions
  - rules
  - aggregation
sidebar_position: 30
---

import Thumbnail from '@site/src/components/Thumbnail';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Aggregation permissions

## Introduction

You can enable access to [aggregation queries](/queries/postgres/aggregation-queries.mdx) for a given role on `select`
operations.

<Tabs groupId="user-preference" className="api-tabs">
<TabItem value="console" label="Console">

You can enable aggregation queries permissions on the Hasura Console by going to: **Data -> [table] -> Permissions -> 
select -> Aggregation queries permissions** and enabling the checkbox as per the below:

<Thumbnail src="/img/auth/authorization_enable-aggregation-permissions-console_2-16.png" alt="Aggregation queries
permissions" width="400px" />

</TabItem>
<TabItem value="cli" label="CLI">

You can allow aggregation query permissions in the `metadata -> databases -> [database-name] -> tables -> [table-name].yaml`
file, eg:

```yaml {10}
- table:
    schema: public
    name: products
  select_permissions:
    - role: user
      permission:
        columns:
          - id
          - name
        allow_aggregations: true
```

Apply the Metadata by running:

```bash
hasura metadata apply
```

</TabItem>
<TabItem value="api" label="API">

You can allow aggregation query permissions when using the
[permissions Metadata API](/api-reference/metadata-api/permission.mdx). Example using a Postgres db:

```http {16}
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
   "type": "pg_create_select_permission",
   "args": {
      "source": "<db_name>",
      "table": "products",
      "role": "user",
      "permission": {
         "columns": [],
         "filter": {
            "id": "X-Hasura-User-Id"
         },
         "allow_aggregations": true
      }
   }
}
```

</TabItem>
</Tabs>

In the above example, the role `user` is allowed to make aggregation queries.